﻿namespace SL651Center2.x.Enums
{
    /// <summary>
    /// 遥测站分类码
    /// </summary>
    public enum TelemetryStationCode : byte
    {
        /// <summary>
        /// 降水
        /// </summary>
        P = 0x50,
        /// <summary>
        /// 河道
        /// </summary>
        H = 0x48,
        /// <summary>
        /// 水库（湖泊）
        /// </summary>
        K = 0x4B,
        /// <summary>
        /// 闸坝
        /// </summary>
        Z = 0x5A,
        /// <summary>
        /// 泵站
        /// </summary>
        D = 0x44,
        /// <summary>
        /// 潮汐
        /// </summary>
        T = 0x54,
        /// <summary>
        /// 墒情
        /// </summary>
        M = 0x4D,
        /// <summary>
        /// 地下水
        /// </summary>
        G = 0x47,
        /// <summary>
        /// 水质
        /// </summary>
        Q = 0x51,
        /// <summary>
        /// 取水口
        /// </summary>
        I = 0x49,
        /// <summary>
        /// 排水口
        /// </summary>
        O = 0x4F
    }

    /// <summary>
    /// 遥测站分类码相关信息
    /// </summary>
    public class TelemetryStationInfo
    {
        /// <summary>
        /// 获取遥测站分类码的名称
        /// </summary>
        /// <param name="code">遥测站分类码</param>
        /// <returns>遥测站分类码的名称</returns>
        public static string GetInfo(TelemetryStationCode code)
        {
            return code switch
            {
                TelemetryStationCode.P => "降水",
                TelemetryStationCode.H => "河道",
                TelemetryStationCode.K => "水库(湖泊)",
                TelemetryStationCode.Z => "闸坝",
                TelemetryStationCode.D => "泵站",
                TelemetryStationCode.T => "潮汐",
                TelemetryStationCode.M => "墒情",
                TelemetryStationCode.G => "地下水",
                TelemetryStationCode.Q => "水质",
                TelemetryStationCode.I => "取水口",
                TelemetryStationCode.O => "排水口",
                _ => "",
            };
        }
        /// <summary>
        /// 获取遥测站分类码的名称
        /// </summary>
        /// <param name="str">遥测站分类码</param>
        /// <returns>遥测站分类码的名称</returns>
        public static string GetInfo(string str)
        {
            if (Enum.IsDefined(typeof(TelemetryStationCode), str))
            {
                var code = (TelemetryStationCode)Enum.Parse(typeof(TelemetryStationCode), str);
                return code switch
                {
                    TelemetryStationCode.P => "降水",
                    TelemetryStationCode.H => "河道",
                    TelemetryStationCode.K => "水库(湖泊)",
                    TelemetryStationCode.Z => "闸坝",
                    TelemetryStationCode.D => "泵站",
                    TelemetryStationCode.T => "潮汐",
                    TelemetryStationCode.M => "墒情",
                    TelemetryStationCode.G => "地下水",
                    TelemetryStationCode.Q => "水质",
                    TelemetryStationCode.I => "取水口",
                    TelemetryStationCode.O => "排水口",
                    _ => "",
                };
            }
            return "";
        }
    }

}
